src_dir = ./cppCode/
src = $(wildcard $(src_dir)*.cpp)
obj = $(patsubst %.cpp, %.o, $(src))
CC = g++
target = $(src_dir)main
debug_src = $(src_dir)main.cpp
debug_target = $(patsubst %.cpp, %, $(debug_src))
cflags = 
lflags = -lpthread 

run: $(target)
	cd $(src_dir) && ./main

math: 
	cd texCode && xelatex MathDocument.tex && mv MathDocument.pdf ../

design:
	cd texCode && xelatex DesignDocument.tex && mv DesignDocument.pdf ../

answers:
	make math
	make design

$(target): $(obj)
	$(CC) $^ -o $@ $(lflags)

$(obj): %.o : %.cpp
	$(CC) -c $< -o $@ $(cflags)

debug: $(debug_src)
	$(CC) -g $< -o $(debug_target)
	gdb $(debug_target) -silent

clean:
	-rm -r $(obj) $(target)
	-rm ./data/*
	-rm ./texCode/*.aux ./texCode/*.log

.PHONY: clean 
